home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 June: Reference Library / Dev.CD Jun 99 RL Disk 1.toast / Technical Documentation / Develop / develop Issue 28 / develop Issue 28 code / MacApp Debugging / TwistDownLists / UTwistDownView.h < prev    next >
Encoding:
Text File  |  1996-07-15  |  9.6 KB  |  228 lines  |  [TEXT/MPS ]

  1. //----------------------------------------------------------------------------------------
  2. // UTwistDownView.h
  3. // ETO20 MacApp 3.3.1, MPW 3.4.1
  4. // Copyright ©1994-1996 Conrad Kopala
  5. // Twist Down Lists version 2.0a0 7/15/96
  6. //----------------------------------------------------------------------------------------
  7.  
  8. #ifndef __UTWISTDOWNVIEW__
  9. #define __UTWISTDOWNVIEW__
  10.  
  11. #ifndef __UTWISTDOWNGLOBALS__
  12. #include "UTwistDownGlobals.h"    //required here for EWritingDirection
  13. #endif
  14.  
  15. //MacApp stuff
  16. #ifndef __UADORNERS__
  17. #include "UAdorners.h"
  18. #endif
  19.  
  20. #ifndef __UDIALOG__
  21. #include "UDialog.h"
  22. #endif
  23.  
  24. #ifndef __UDRAWINGENVIRONMENT__
  25. #include "UDrawingEnvironment.h"
  26. #endif
  27.  
  28. #ifndef __UGRIDVIEW__
  29. #include "UGridView.h"
  30. #endif
  31.  
  32. #ifndef __UCOMMAND__
  33. #include "UCommand.h"
  34. #endif
  35.  
  36. //ToolBox stuff
  37.  
  38. #ifndef __TEXTEDIT__
  39. #include "TextEdit.h"        //Needed for TextStyle PPC
  40. #endif
  41.  
  42. //ANSI stuff
  43. //None
  44. //----------------------------------------------------------------------------------------
  45. // Forward and external classes
  46. //----------------------------------------------------------------------------------------
  47. class TTwistDownApp;                //external
  48. class TTwistDownDocument;        //external
  49. class TTwistDownElement;        //external
  50. class TTwistDownControl;        //external
  51. class TTwistDownView;                //forward
  52.  
  53.  
  54. //----------------------------------------------------------------------------------------
  55. // TChangeFontSizeDialog
  56. //----------------------------------------------------------------------------------------
  57. class TChangeFontSizeDialog: public TView
  58. {
  59.     MA_DECLARE_CLASS;
  60.     
  61. public:
  62. TChangeFontSizeDialog::TChangeFontSizeDialog(); 
  63. virtual ~TChangeFontSizeDialog();
  64. void TChangeFontSizeDialog::IChangeFontSizeDialog(TDocument* itsDocument,TView* itsSuperView,
  65.                   const VPoint& itsLocation,const VPoint& itsSize,SizeDeterminer itsHSizeDet,SizeDeterminer itsVSizeDet);
  66.  
  67. void TChangeFontSizeDialog::GetNewFontSize(long& newSize);
  68. void TChangeFontSizeDialog::SetNewSize(long& newSize);
  69. };
  70.  
  71. //----------------------------------------------------------------------------------------
  72. // TTwistDownView
  73. //----------------------------------------------------------------------------------------
  74. class TTwistDownView: public TTextListView, public MScriptableObject
  75. {
  76.     MA_DECLARE_CLASS;
  77.     
  78. public:
  79. TTwistDownDocument* fTwistDownDocument;
  80. VPoint fTwistDownControlSize;
  81. PolyHandle fOpenTriangle;
  82. PolyHandle fClosedTriangle;
  83. PolyHandle fIntermediateTriangle;
  84. Boolean fCouldExpandAll;
  85. Boolean fCouldCollapseAll;
  86.  
  87. Boolean fIsFirstClick;
  88.  
  89. long fNumberOfControls;    //This is used to keep a running count of the number of controls that exist
  90.                                                 //at any time. When a new twistDownControl is made, fNumberOfControls is
  91.                                                 //incremented. When a twistDownControl is freed, fNumberOfControls is
  92.                                                 //decremented. Having this count available is useful for finding mistakes in
  93.                                                 //the program.
  94.  
  95. long fInitialNumberOfControls;    //This is the number of controls that existed when the document opened.
  96.                                                                 //It never changes after the document is opened. Note that
  97.                                                                 //fNumberOfControls can never be less than fInitialNumberOfControls.
  98.                                                                 
  99. Boolean fControlCountingEnabled;    //This is used in conjunction with fInitialNumberOfControls
  100.                                                                     //and IncrementInitialNumberOfControls(). fControlCountingEnabled
  101.                                                                     //is initially set to FALSE. While it is FALSE, fInitialNumberOfControls
  102.                                                                     //is incremented. The last thing CreateVisibleList() does is
  103.                                                                     //set fControlCountingEnabled to TRUE.
  104.  
  105. long fNumberOfExpandedControls;        //A running count of the number of expanded controls and
  106. long fNumberOfCollapsedControls;    //collapsed controls is kept. 
  107.  
  108. EWritingDirection fWritingDirection;
  109.  
  110. VPoint fTwistDownControlLocation;    //This is used to hold the horizontal coordinate of twistDownControls.
  111.                                                                     //If we're writing left-to-right, the controls are on the left side of
  112.                                                                     //the twistDownView. If we're writing right-to-left, the controls are 
  113.                                                                     //on the right side of the twistDownView.
  114.                                                                     //fTwistDownControlLocation.v = 0 always.
  115.                                                                     //if GetSysDirection() == 0 (writing left-to-right) then 
  116.                                                                     //fTwistDownControlLocation.h = 0.
  117.                                                                     //
  118.                                                                     //if GetSystemDirection() == -1 (writing right-to-left) then
  119.                                                                     //fTwistDownControlLocation.h 
  120.                                                                     //    = TTwistDownView.fSize.h - TTwistDownView.fTwistDownControlSize.h.
  121.                                                                     //
  122.                                                                     //Its value is set by TTwistDownView::CreateTwistDownTriangles which is 
  123.                                                                     //where fTwistDownControlSize is determined (fTwistDownControlSize is 
  124.                                                                     //dependent on the font size). 
  125.                                                                     //
  126.                                                                     //Its value is also set by TTwistDownView::SuperViewChangedFrame which
  127.                                                                     //is called when the window's size is changed. The frame and size of
  128.                                                                     //the twistDownView is changed by SetFrame which in turn calls 
  129.                                                                     //NotifySubViewsOfFrameChange. We need to set the value of 
  130.                                                                     //fTwistDownControlLocation.h before the twistDownControls are notified that 
  131.                                                                     //their superview has changed its frame. 
  132.  
  133. TTwistDownView::TTwistDownView(); 
  134. virtual ~TTwistDownView(); 
  135.  
  136. virtual void TTwistDownView::ITwistDownView(TTwistDownDocument* itsDocument, TView* itsSuperView,
  137.                                             const VPoint& itsLocation, const VPoint& itsSize);
  138.                                             
  139. virtual void TTwistDownView::DoPostCreate(TDocument* itsDocument);
  140.  
  141. virtual void TTwistDownView::DoSetupMenus();
  142. virtual void TTwistDownView::DoMenuCommand(CommandNumber aCommandNumber);
  143.  
  144. virtual Boolean TTwistDownView::HandleMouseDown(const VPoint& theMouse,TToolboxEvent* event, 
  145.                                                         CPoint hysteresis,EMouseDownType    mouseDownType);
  146.                                                         
  147. void TTwistDownView::GetViewSize(VPoint& viewSize);
  148.  
  149. OSErr TTwistDownView::CreateVisibleList();
  150. OSErr TTwistDownView::BuildVisibleList(short rowNumber);
  151. void TTwistDownView::ResizeTwistDownViewRows();
  152. short TTwistDownView::CalculateColumnWidth();
  153. void TTwistDownView::RevealRight(Boolean redraw);
  154.                                         
  155. virtual void TTwistDownView::SuperViewChangedFrame(const VRect& oldFrame,const VRect& newFrame,Boolean invalidate);                                         
  156.  
  157. // SubView management
  158. TTwistDownControl* TTwistDownView::NewTwistDownControl(TTwistDownElement* twistDownElement, 
  159.                                                                                                             VPoint& itsLocation, OSErr &myOSErr);
  160. void TTwistDownView::AddTwistDownControls(TTwistDownElement* twistDownElement, short &rowNumber, OSErr& myOSErr);
  161. void TTwistDownView::DeleteTwistDownControls(TTwistDownElement* twistDownElement);
  162. void TTwistDownView::RestoreTwistDownControls(TTwistDownElement* twistDownElement);
  163. void TTwistDownView::RemoveTwistDownControl(TTwistDownElement* twistDownElement);
  164. void TTwistDownView::UpdateTwistDownControlLocations(TTwistDownElement* twistDownElement, short &rowNumber);
  165.  
  166. // Drawing
  167. short TTwistDownView::GetItemTextToDisplay(short anItem, CStr63& aString);
  168.  
  169. short TTwistDownView::GetTextToDisplay(GridCell aCell, CStr63& aString);
  170. virtual void TTwistDownView::DrawCell(GridCell aCell, const VRect& aRect);
  171.  
  172. Boolean TTwistDownView::GetNewFontSize(CommandNumber aCommandNumber,long& newFontSize);
  173. void TTwistDownView::DoChangeTextStyle(const TextStyle& itsTextStyle);
  174. void TTwistDownView::DoChangeFontSize(short newFontSize);
  175. void TTwistDownView::DoChangeFont(CStr255 newFontName);
  176. void TTwistDownView::DoChangeWritingDirection(EWritingDirection newWritingDirection);
  177.  
  178. VPoint TTwistDownView::GetTwistDownControlSize();
  179.  
  180. void TTwistDownView::CreateTwistDownTriangles();
  181. PolyHandle TTwistDownView::GetOpenTriangle();
  182. PolyHandle TTwistDownView::GetClosedTriangle();
  183. PolyHandle TTwistDownView::GetIntermediateTriangle();
  184.  
  185. void TTwistDownView::IncrementNumberOfControls();
  186. void TTwistDownView::DecrementNumberOfControls();
  187. long TTwistDownView::GetNumberOfControls();
  188.  
  189. //These are used to manage the enabling of cExpandAll and cCollapseAll
  190. void TTwistDownView::IncrementNumberOfExpandedControls();
  191. void TTwistDownView::DecrementNumberOfExpandedControls();
  192.  
  193. void TTwistDownView::IncrementNumberOfCollapsedControls();
  194. void TTwistDownView::DecrementNumberOfCollapsedControls();
  195.  
  196. //The following four methods are used to manage error recovery from failed TExpandAllCommands
  197. long TTwistDownView::GetNumberOfExpandedControls();
  198. void TTwistDownView::SetNumberOfExpandedControlsTo(long numberOfControls);
  199. long TTwistDownView::GetNumberOfCollapsedControls();
  200. void TTwistDownView::SetNumberOfCollapsedControlsTo(long numberOfControls);
  201.  
  202. //These are used to set the values of fCouldExpandAll and fCouldCollapseAll.
  203. void TTwistDownView::SetCantExpandAll();
  204. void TTwistDownView::SetCantCollapseAll();
  205. void TTwistDownView::SetTheCouldFlags();
  206.  
  207. void TTwistDownView::IncrementInitialNumberOfControls();
  208. Boolean TTwistDownView::ControlCountingEnabled();
  209.  
  210. // Scripting support
  211. virtual void TTwistDownView::DoScriptCommand(CommandNumber aCommandNumber,TAppleEvent* message,TAppleEvent* reply);
  212. virtual DescType TTwistDownView::GetSpecifierForm();
  213. virtual Boolean TTwistDownView::GetObjectProperty(CAEDesc& thePropertyValue,DescType whichProperty,
  214.                                                                                     const CAEDesc& desiredType);
  215.                                                                                     
  216. virtual void TTwistDownView::GetSetPropertyInfo(DescType whichProperty,CommandNumber& cmdNum,
  217.                                 Boolean& canUndo,Boolean& causesChange,TCommandHandler* &theContext);
  218.                                 
  219. virtual void TTwistDownView::SetObjectProperty(const CAEDesc& thePropertyValue,DescType whichProperty);                                
  220. };
  221.  
  222. //----------------------------------------------------------------------------------------
  223. // Global initialization procedure
  224. //----------------------------------------------------------------------------------------
  225. extern void InitUTwistDownView();
  226.  
  227. #endif
  228.